package client

import (
	"bufio"
	"bytes"
	"io"
	"net/http"
)

type FileEntry struct {
	FileName string
	FileData []byte
}

func NewFromReader(fileName string, r io.Reader) *FileEntry {
	bf := bytes.Buffer{}
	bf.ReadFrom(r)
	data := bf.Bytes()
	return &FileEntry{FileName: fileName, FileData: data}

}

func (f *FileEntry) Reader() io.Reader {
	r := bytes.NewReader(f.FileData)
	return bufio.NewReader(r)
}

func (f *FileEntry) Size() int {
	return len(f.FileData)
}

func (f *FileEntry) ContentType() string {
	return http.DetectContentType(f.FileData)
}
